home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 115 / cd-rom 115.iso / capa / interat / Program / Scripts / KRDemos / docinfo.wbs < prev    next >
Encoding:
Text File  |  1996-12-09  |  40.4 KB  |  1,307 lines

  1. ' ******************************************************************************
  2. ' DOCINFO.WBS - WRITE SIMULATION INFORMATION TO A FILE
  3. '    
  4. '    This Working Model script writes prints simulation information from
  5. '    the active Working Model document to a user specified file.  Users
  6. '    can select what types of simulation entities to print from a dialog.
  7. '    A help dialog is displayed upon request.
  8. '
  9. ' Version 1.0, Created by Knowledge Revolution
  10. ' (C) Copyright Knowledge Revolution 1995   All Rights Reserved
  11. '
  12. ' ******************************************************************************
  13. Dim MyDoc as WMDocument
  14.  
  15. Const vernum as string = "1.0"
  16.  
  17. Const BlankLine as string = " "
  18. Const UChar as string = "-"
  19. Const Spaces as string = "                    "
  20. Dim CRLF as string
  21.  
  22. Dim vp as boolean
  23. Dim numdec as integer
  24.  
  25. Dim Helpset as boolean
  26. Dim Cancelflag as boolean
  27.  
  28. Public firstin as integer
  29.  
  30. Public HeaderFlag as boolean
  31. Public UnitFlag as boolean
  32. Public EngineFlag as boolean
  33. Public BodyFlag as boolean
  34. Public PinFlag as boolean
  35. Public SpringFlag as boolean
  36. Public DamperFlag as boolean
  37. Public SpringDamperFlag as boolean
  38. Public RotSpringFlag as boolean
  39. Public RotDamperFlag as boolean
  40. Public RodRopeSepFlag as boolean
  41. Public LinearSlotFlag as boolean
  42. Public CurvedSlotFlag as boolean
  43. Public ForceFlag as boolean
  44. Public TorqueFlag as boolean
  45. Public MotorActuatorFlag as boolean
  46. Public PulleyFlag as boolean
  47. Public GearFlag as boolean
  48. Public PointFlag as boolean
  49.  
  50. Function Strcell(x as wmcell, sigdigits as integer) as string
  51. '-------------------------------------------------------------------
  52. '    This function takes a WMCell and formats either a number or
  53. '    the WMCells equation to fit in a string sigdigits wide.
  54. '-------------------------------------------------------------------
  55.  
  56.  
  57.     dim temp1 as string
  58.     dim temp2 as string * 12
  59.  
  60.     if x.formula <> "" then
  61.         if len(x.formula) > 11 then
  62.             strcell = "    equation"
  63.         else
  64.             strcell = " " + right(spaces + x.formula,11)
  65.         end if
  66.     else
  67.         temp1 = Format(x.value, "0." + string(sigdigits,"0")) 
  68.  
  69.            if len(temp1) > 10 then
  70.                temp1 = "xxxxxxxxx"
  71.            end if
  72.        
  73.            rset temp2 = temp1
  74.            strcell = temp2
  75.     end if
  76. end function
  77.  
  78. Function Strnum(x as double, sigdigits as integer) as string
  79. '-------------------------------------------------------------------
  80. '    This function formats a string from a number passed to it.  The 
  81. '    string is left justified, and will have sigdigits decimal places.
  82. '    If it the original is longer than 10, the string is returned as
  83. '    all XXXXXX.
  84. '-------------------------------------------------------------------
  85.  
  86.      dim temp1 as string
  87.     dim temp2 as string * 12
  88.  
  89.     temp1 = Format(x, "0." + string(sigdigits,"0")) 
  90.        if len(temp1) > 10 then
  91.            temp1 = "xxxxxxxxx"
  92.      end if
  93.       
  94.       rset temp2 = temp1
  95.        Strnum = temp2
  96. end function
  97.  
  98. function OpenPrintFile as boolean
  99. '-------------------------------------------------------------------
  100. '    This function opens a file or a viewport (Windows only) based
  101. '    upon a users input.  It returns a true if the file was opened
  102. '    successfully, false if not.
  103. '-------------------------------------------------------------------
  104.  
  105.     Dim F as string
  106.  
  107.     openprintfile = false
  108.  
  109.     If Basic.OS = ebwin16 or Basic.OS = ebwin32 then    ' Running windows
  110.         crlf = chr$(13) + chr$(10)
  111.         r%=answerbox("Dump to a viewport or to a file?", "ViewPort", "File", "Cancel")
  112.         if r = 1 then
  113.             ViewPortOpen
  114.             openprintfile = true
  115.             vp = true
  116.         else 
  117.             if r = 2 then
  118.                    F = SaveFileName$("Select/Create Output File","Text Files:*.TXT")
  119.                    If F<>"" then
  120.                        Open f for output as #1
  121.                        openprintfile = true
  122.                     vp = false
  123.                    end if
  124.             end if
  125.         end if
  126.     elseIf Basic.OS = ebmacintosh then            ' Running Macintosh
  127.         crlf = chr$(13)
  128.           F = SaveFileName$("Select/Create Output File","TEXT")
  129.            If F<>"" then
  130.                Open f for output as #1
  131.                openprintfile = true
  132.             vp = false
  133.            end if
  134.     else                            ' Unknown OS
  135.         MsgBox "Running Unknown Operating System " + Basic.OS
  136.     end If
  137.  
  138. end function
  139.     
  140. Sub P (l as string)
  141. '-------------------------------------------------------------------
  142. '    This subroutine takes the string L and writes it either to the
  143. '    Viewport (Windows only) or file #1, depending on what the user
  144. '    selected in the OpenPrintFile routine above.
  145. '-------------------------------------------------------------------
  146.  
  147.     If VP then
  148.         Print l
  149.     else
  150.         Print #1, l
  151.     end if
  152.  
  153. End sub
  154.  
  155. Sub PrintHeader
  156. '-------------------------------------------------------------------
  157. '    Prints the file header
  158. '-------------------------------------------------------------------
  159.  
  160.     p "Working Model Information Export Utility     version " + vernum
  161.     p "Date: " + Date$
  162.     p "Time: " + Time$
  163.     p "Working Model Version: "
  164.     p "Simulation File: " + Mydoc.name
  165.  
  166. end sub
  167.  
  168. Sub PrintUnits
  169. '-------------------------------------------------------------------
  170. '    Prints the Unit section of the file.
  171. '-------------------------------------------------------------------
  172.  
  173.     dim l as string
  174.  
  175.     p blankline
  176.     p blankline
  177.     p "Section:  Unit System"
  178.     p blankline
  179.     l = "Distance:   " + left(mydoc.distanceunit + spaces,16)
  180.     l = l + "   Energy:   " + left(mydoc.energyunit + spaces,16)
  181.     l = l + "   Force:   " + left(mydoc.forceunit + spaces,16)
  182.     l = l + "   Frequency:   " + left(mydoc.frequencyunit + spaces,16)
  183.     p l
  184.     l = "Mass:       " + left(mydoc.massunit + spaces,16)
  185.     l = l + "   Power:    " + left(mydoc.powerunit + spaces,16)
  186.     l = l + "   Time:    " + left(mydoc.timeunit + spaces,16)
  187.     l = l + "   Velocity:    " + left(mydoc.velocityunit + spaces,16)
  188.     p l
  189.  
  190. end sub
  191.  
  192. Sub PrintEngine
  193. '-------------------------------------------------------------------
  194. '    Prints the information on the simulation engine settings.
  195. '-------------------------------------------------------------------
  196.  
  197.     dim l as string    
  198.  
  199.     p blankline
  200.     p blankline
  201.     p "Section:  Integration Settings"
  202.     p blankline
  203.     p "                         Variable/       Animation    Overlap     Assembly                 Gravity"
  204.     p "Integrator                Fixed            Step        Error       Error       Gravity     Constant"
  205.     p string(118,uchar)
  206.     p blankline
  207.     l = left(mydoc.integrator + spaces, 23)
  208.     if mydoc.variableintegrationstep then
  209.         l = l + "  Variable   "
  210.     else
  211.         l = l + "   Fixed     "
  212.     end if
  213.     l = l + strnum(mydoc.animationstep,numdec)
  214.     l = l + strnum(mydoc.overlaperror,numdec)
  215.     l = l + strnum(mydoc.assemblyerror,numdec)
  216.     if mydoc.gravity = "none" then
  217.         l = l + "         None"
  218.     else
  219.         if mydoc.gravity = "linear" then
  220.             l = l + "        Linear" + strnum(mydoc.lineargravityconst,numdec)
  221.         else
  222.             l = l + "      Planetary" + strnum(mydoc.planetarygravityconst,numdec)
  223.         end if
  224.     end if
  225.     p l
  226.  
  227. End sub
  228.  
  229. Sub Printbodies
  230. '-------------------------------------------------------------------
  231. '    Prints information on the bodies in the simulation.  The routine
  232. '    first writes the section header, then loops through all bodies
  233. '    and writes information on each.  Circles, rectangles, and polygons
  234. '    have sections with slightly different formats.
  235. '-------------------------------------------------------------------
  236.  
  237.     dim l as string
  238.     dim x as double
  239.     dim y as double
  240.     dim i1 as integer    
  241.  
  242.     p blankline
  243.     p blankline
  244.     p "Section:  Bodies"
  245.     p blankline
  246.     p "Body      Name        Kind      Px/         Vx/         Mass/       Sfric/    Geometry"
  247.     p "                                Py/         Vy/         Area/       Kfric"
  248.     p "                                Pr          Vr          Density     COR"
  249.     p string(118,uchar)
  250.  
  251.     for i = 1 to mydoc.bodies.count
  252.         p blankline
  253.          l = left("Body[" + cstr(Mydoc.bodies.item(i).id) + "]" + spaces,10)
  254.          l = l + left(mydoc.bodies.item(i).name + spaces,10) + "  "
  255.          l = l + left(mydoc.bodies.item(i).kind + spaces,4)
  256.          l = l + strcell(mydoc.bodies.item(i).px,numdec)
  257.          l = l + strcell(mydoc.bodies.item(i).vx,numdec)
  258.          l = l + strcell(mydoc.bodies.item(i).mass,numdec)
  259.          l = l + strcell(mydoc.bodies.item(i).staticfriction,numdec)
  260.         if mydoc.bodies.item(i).kind = "rectangle" then
  261.             l = l + "    Height: " + strcell(mydoc.bodies.item(i).height,numdec)
  262.         else
  263.             if mydoc.bodies.item(i).kind = "circle" then
  264.                  l = l + "    Radius: " + strcell(mydoc.bodies.item(i).radius,numdec)
  265.             else
  266.                 mydoc.bodies.item(i).getvertex 1,x,y
  267.                  l = l + "    V1x:  " + strnum(x,numdec) + "  V1y:  " + strnum(y,numdec)
  268.             end if
  269.         end if
  270.         p l
  271.  
  272.         l = string(26, " ")
  273.          l = l + strcell(mydoc.bodies.item(i).py,numdec)
  274.          l = l + strcell(mydoc.bodies.item(i).vy,numdec)
  275.          l = l + "        area"
  276.          l = l + strcell(mydoc.bodies.item(i).kineticfriction,numdec)
  277.         if mydoc.bodies.item(i).kind = "rectangle" then
  278.             l = l + "    Width:  " + strcell(mydoc.bodies.item(i).width,numdec)
  279.         else
  280.              if mydoc.bodies.item(i).kind = "polygon" then
  281.                 mydoc.bodies.item(i).getvertex 2,x,y
  282.                    l = l + "    V2x:  " + strnum(x,numdec) + "  V2y:  " + strnum(y,numdec)
  283.                end if
  284.         end if
  285.         p l
  286.  
  287.         l = string(26, " ")
  288.          l = l + strcell(mydoc.bodies.item(i).pr,numdec)
  289.          l = l + strcell(mydoc.bodies.item(i).vr,numdec)
  290.          l = l + "     density"
  291.          l = l + strcell(mydoc.bodies.item(i).elasticity,numdec)
  292.         if mydoc.bodies.item(i).kind = "polygon" then
  293.             mydoc.bodies.item(i).getvertex 3,x,y
  294.                l = l + "    V3x:  " + strnum(x,numdec) + "  V3y:  " + strnum(y,numdec)
  295.            end if
  296.         p l      
  297.  
  298.         if mydoc.bodies.item(i).kind = "polygon" then
  299.             for i1 = 4 to mydoc.bodies.item(i).vertexcount
  300.                 mydoc.bodies.item(i).getvertex i1,x,y
  301.                   l = string(74," ")
  302.                 l = l + left("    V" + cstr(i1) + "x:" + "          ",10)
  303.                 l = l + strnum(x,numdec)
  304.                 l = l +    left("  V" + cstr(i1) + "y:" + "          ",8)
  305.                 l = l + strnum(y,numdec)
  306.                 p l
  307.             next i1
  308.         end if
  309.               
  310.     next i
  311.  
  312. end sub
  313.  
  314. sub PrintConstraints
  315. '-------------------------------------------------------------------
  316. '    Prints header information on the constraints in the simulation. 
  317. '    After formatting the header information, a constraint specific
  318. '    routine is called for each instance of the constraint type.  Each
  319. '    class of constraints has different properties, so each is 
  320. '    formatted and handled separately.
  321. '-------------------------------------------------------------------
  322.  
  323.     if pinflag then
  324.         headflag = true
  325.         for i = 1 to mydoc.constraints.count
  326.             if mydoc.constraints.item(i).kind = "pin" then
  327.                 if headflag then
  328.                     p blankline
  329.                        p blankline
  330.                        p "Section:  Pins"
  331.                         p blankline
  332.                           p "Constraint      Name         Kind      Body1/     Point1/       P1x/        P1y/        Active When"
  333.                       p "                                       Body2      Point2        P2x         P2y"
  334.                           p string(118,uchar)
  335.                     headflag = false
  336.                 end if
  337.                  formatpin mydoc.constraints.item(i)
  338.             end if
  339.         next i
  340.     end if
  341.  
  342.     if springflag then
  343.         headflag = true
  344.         for i = 1 to mydoc.constraints.count
  345.             if mydoc.constraints.item(i).kind = "spring" then
  346.                 if headflag then
  347.                     p blankline
  348.                        p blankline
  349.                        p "Section:  Springs"
  350.                         p blankline
  351.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/        K/          Rlength/"
  352.                       p "                             Body2      Point2        P2x         P2y         Exp         Clength      Active When"
  353.                           p string(118,uchar)
  354.                     headflag = false
  355.                 end if
  356.                  formatspring mydoc.constraints.item(i)
  357.             end if
  358.         next i
  359.     end if
  360.  
  361.     if damperflag then
  362.         headflag = true
  363.         for i = 1 to mydoc.constraints.count
  364.             if mydoc.constraints.item(i).kind = "damper" then
  365.                 if headflag then
  366.                     p blankline
  367.                        p blankline
  368.                        p "Section:  Dampers"
  369.                         p blankline
  370.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/        K/"
  371.                       p "                             Body2      Point2        P2x         P2y         Exp          Active When"
  372.                           p string(118,uchar)
  373.                     headflag = false
  374.                 end if
  375.                  formatspring mydoc.constraints.item(i)
  376.             end if
  377.         next i
  378.     end if
  379.  
  380.     if springdamperflag then
  381.         headflag = true
  382.         for i = 1 to mydoc.constraints.count
  383.             if mydoc.constraints.item(i).kind = "springdamper" then
  384.                 if headflag then
  385.                     p blankline
  386.                        p blankline
  387.                        p "Section:  Spring/Dampers"
  388.                         p blankline
  389.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/        SK/         Rlength/"
  390.                       p "                             Body2      Point2        P2x         P2y         DK          Clength      Active When"
  391.                           p string(118,uchar)
  392.                     headflag = false
  393.                 end if
  394.                  formatspringdamper mydoc.constraints.item(i)
  395.             end if
  396.         next i
  397.     end if
  398.  
  399.     if rotspringflag then
  400.         headflag = true
  401.         for i = 1 to mydoc.constraints.count
  402.             if mydoc.constraints.item(i).kind = "rotationalspring" then
  403.                 if headflag then
  404.                     p blankline
  405.                        p blankline
  406.                        p "Section:  Rotational Springs"
  407.                         p blankline
  408.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/        K/          Rotation/"
  409.                       p "                             Body2      Point2        P2x         P2y         Exp         CRotation    Active When"
  410.                           p string(118,uchar)
  411.                     headflag = false
  412.                 end if
  413.                  formatrspring mydoc.constraints.item(i)
  414.             end if
  415.         next i
  416.     end if
  417.  
  418.     if rotdamperflag then
  419.         headflag = true
  420.         for i = 1 to mydoc.constraints.count
  421.             if mydoc.constraints.item(i).kind = "rotationaldamper" then
  422.                 if headflag then
  423.                     p blankline
  424.                        p blankline
  425.                        p "Section:  Rotational Dampers"
  426.                         p blankline
  427.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/        K/"
  428.                       p "                             Body2      Point2        P2x         P2y         Exp         Active When"
  429.                           p string(118,uchar)
  430.                     headflag = false
  431.                 end if
  432.                  formatrspring mydoc.constraints.item(i)
  433.             end if
  434.         next i
  435.     end if
  436.  
  437.     if rodropesepflag then
  438.         headflag = true
  439.         for i = 1 to mydoc.constraints.count
  440.             if mydoc.constraints.item(i).kind = "rod" or _
  441.                 mydoc.constraints.item(i).kind = "rope" or _
  442.                 mydoc.constraints.item(i).kind = "separator" then
  443.                 if headflag then
  444.                     p blankline
  445.                        p blankline
  446.                        p "Section:  Rods, Ropes, and Separators"
  447.                         p blankline
  448.                           p "Constraint      Name         Kind      Body1/     Point1/       P1x/        P1y/        Length/     Elasticity/"
  449.                       p "                                       Body2      Point2        P2x         P2y         CLength     Active When"
  450.                           p string(118,uchar)
  451.                     headflag = false
  452.                 end if
  453.                  formatrodropesep mydoc.constraints.item(i)
  454.             end if
  455.         next i
  456.     end if
  457.  
  458.     if MotorActuatorFlag then
  459.         headflag = true
  460.         for i = 1 to mydoc.constraints.count
  461.             if mydoc.constraints.item(i).kind = "motor" or _
  462.                 mydoc.constraints.item(i).kind = "actuator" then
  463.                 if headflag then
  464.                     p blankline
  465.                        p blankline
  466.                        p "Section:  Motors and Actuators"
  467.                         p blankline
  468.                           p "Constraint      Name         Kind      Body1/     Point1/       P1x/        P1y/        Type/       Active When"
  469.                       p "                                       Body2      Point2        P2x         P2y         Value"
  470.                           p string(118,uchar)
  471.                     headflag = false
  472.                 end if
  473.                  formatmotact mydoc.constraints.item(i)
  474.             end if
  475.         next i
  476.     end if
  477.  
  478.     if ForceFlag then
  479.         headflag = true
  480.         for i = 1 to mydoc.constraints.count
  481.             if mydoc.constraints.item(i).kind = "force" then
  482.                 if headflag then
  483.                     p blankline
  484.                        p blankline
  485.                        p "Section:  Forces"
  486.                         p blankline
  487.                           p "Constraint      Name         Body1      Point1        P1x/        Fx/         Rotate       Active When"
  488.                       p "                                                      P1y         Fy"        
  489.                           p string(118,uchar)
  490.                     headflag = false
  491.                 end if
  492.                  formatforce mydoc.constraints.item(i)
  493.             end if
  494.         next i
  495.     end if
  496.  
  497.     if TorqueFlag then
  498.         headflag = true
  499.         for i = 1 to mydoc.constraints.count
  500.             if mydoc.constraints.item(i).kind = "torque" then
  501.                 if headflag then
  502.                     p blankline
  503.                        p blankline
  504.                        p "Section:  Torques"
  505.                         p blankline
  506.                           p "Constraint      Name         Body1      Point1        P1x         P1y         Torque       Active When"
  507.                           p string(118,uchar)
  508.                     headflag = false
  509.                 end if
  510.                  formattorque mydoc.constraints.item(i)
  511.             end if
  512.         next i
  513.     end if
  514.  
  515.     if curvedslotflag then
  516.         headflag = true
  517.         for i = 1 to mydoc.constraints.count
  518.             if mydoc.constraints.item(i).kind = "curvedslot" then
  519.                 if headflag then
  520.                     p blankline
  521.                        p blankline
  522.                        p "Section:  Curved Slots"
  523.                         p blankline
  524.                           p "Constraint      Name         Kind      Body1/     Point1/       P1x/        P1y/         Active When"
  525.                       p "                                       Body2      Point2        P2x         P2y          V1x:        V1Y:"
  526.                           p string(118,uchar)
  527.                     headflag = false
  528.                 end if
  529.                  formatcurvedslot mydoc.constraints.item(i)
  530.             end if
  531.         next i
  532.     end if
  533.  
  534.     if linearslotflag then
  535.         headflag = true
  536.         for i = 1 to mydoc.constraints.count
  537.             if mydoc.constraints.item(i).kind = "slot" then
  538.                 if headflag then
  539.                     p blankline
  540.                        p blankline
  541.                        p "Section:  Linear Slots"
  542.                         p blankline
  543.                           p "Constraint      Name         Body1/     Point1/       P1x/        P1y/         R1/"
  544.                       p "                             Body2      Point2        P2x         P2y          R2        Active When"
  545.                           p string(118,uchar)
  546.                     headflag = false
  547.                 end if
  548.                  formatlinearslot mydoc.constraints.item(i)
  549.             end if
  550.         next i
  551.     end if
  552.  
  553.     if pulleyflag then
  554.         headflag = true
  555.         for i = 1 to mydoc.constraints.count
  556.             if mydoc.constraints.item(i).kind = "pulley" then
  557.                 if headflag then
  558.                     p blankline
  559.                        p blankline
  560.                        p "Section:  Pulleys"
  561.                         p blankline
  562.                           p "Constraint      Name         Point       Body        Px          Py          Active When"
  563.                           p string(118,uchar)                                         
  564.                     headflag = false
  565.                 end if
  566.                  formatpulley mydoc.constraints.item(i)
  567.             end if
  568.         next i
  569.     end if
  570.  
  571.     if gearflag then
  572.         headflag = true
  573.         for i = 1 to mydoc.constraints.count
  574.             if mydoc.constraints.item(i).kind = "gear" then
  575.                 if headflag then
  576.                     p blankline
  577.                        p blankline
  578.                        p "Section:  Gears"
  579.                         p blankline
  580.                           p "Constraint      Name        Ratio        RodActive   Body1/      Internal1/  Active When"
  581.                           p "                                                     Body2       Internal2"
  582.                           p string(118,uchar)                                         
  583.                     headflag = false
  584.                 end if
  585.                  formatgear mydoc.constraints.item(i)
  586.             end if
  587.         next i
  588.     end if
  589.  
  590. end sub
  591.  
  592. sub formatpin(pin as wmconstraint)
  593. '-------------------------------------------------------------------
  594. '    Formats and prints detail information on the pin passed to it.
  595. '-------------------------------------------------------------------
  596.     
  597.     dim l as string
  598.     
  599.     p blankline
  600.      l = left("Constraint[" + cstr(pin.id) + "]" + spaces,16)
  601.      l = l + left(pin.name + spaces,11) + "  "
  602.     l = l + left(pin.kind + spaces,9)
  603.     l = l + left("body[" + cstr(pin.point(1).body.id) + "]" + spaces,11)
  604.     l = l + left("point[" + cstr(pin.point(1).id) + "]" + spaces,9)
  605.     l = l + strcell(pin.point(1).px,numdec)
  606.     l = l + strcell(pin.point(1).py,numdec)
  607.     if pin.alwaysactive then
  608.         l = l + "      Always"
  609.     else
  610.         l = l + "      " + pin.activewhen.formula
  611.     end if
  612.     p l
  613.  
  614.     l = string(38, " ") + left("body[" + cstr(pin.point(2).body.id) + "]" + spaces,11)
  615.     l = l + left("point[" + cstr(pin.point(2).id) + "]" + spaces,9)
  616.     l = l + strcell(pin.point(2).px,numdec)
  617.     l = l + strcell(pin.point(2).py,numdec)
  618.     p l
  619.     
  620. end sub
  621.  
  622. sub formatspring(spring as wmconstraint)
  623. '-------------------------------------------------------------------
  624. '    Formats and prints detail information on the spring passed to it.
  625. '-------------------------------------------------------------------
  626.     
  627.     dim l as string
  628.     
  629.     p blankline
  630.      l = left("Constraint[" + cstr(spring.id) + "]" + spaces,16)
  631.      l = l + left(spring.name + spaces,11) + "  "
  632.     l = l + left("body[" + cstr(spring.point(1).body.id) + "]" + spaces,11)
  633.     l = l + left("point[" + cstr(spring.point(1).id) + "]" + spaces,9)
  634.     l = l + strcell(spring.point(1).px,numdec)
  635.     l = l + strcell(spring.point(1).py,numdec)
  636.     l = l + strcell(spring.k,numdec)
  637.     if spring.kind = "spring" then
  638.         l = l + strcell(spring.length,numdec)
  639.     end if
  640.     p l
  641.  
  642.     l = string(29, " ") + left("body[" + cstr(spring.point(2).body.id) + "]" + spaces,11)
  643.     l = l + left("point[" + cstr(spring.point(2).id) + "]" + spaces,9)
  644.     l = l + strcell(spring.point(2).px,numdec)
  645.     l = l + strcell(spring.point(2).py,numdec)
  646.     l = l + right("        " + cstr(spring.exponent) + "    ", 12)
  647.     if spring.kind = "spring" then
  648.         l = l + strnum(spring.currentlength,numdec)
  649.     end if
  650.     if spring.alwaysactive then
  651.         l = l + "      Always"
  652.     else
  653.         l = l + "      " + spring.activewhen.formula
  654.     end if
  655.  
  656.     p l
  657.     
  658. end sub
  659.  
  660. sub formatspringdamper(sd as wmconstraint)
  661. '-------------------------------------------------------------------
  662. '    Formats and prints detail information on the springdamper 
  663. '    passed to it.
  664. '-------------------------------------------------------------------
  665.     
  666.     dim l as string
  667.     
  668.     p blankline
  669.      l = left("Constraint[" + cstr(sd.id) + "]" + spaces,16)
  670.      l = l + left(sd.name + spaces,11) + "  "
  671.     l = l + left("body[" + cstr(sd.point(1).body.id) + "]" + spaces,11)
  672.     l = l + left("point[" + cstr(sd.point(1).id) + "]" + spaces,9)
  673.     l = l + strcell(sd.point(1).px,numdec)
  674.     l = l + strcell(sd.point(1).py,numdec)
  675.     l = l + strcell(sd.k,numdec)
  676.     l = l + strcell(sd.length,numdec)
  677.     p l
  678.  
  679.     l = string(29, " ") + left("body[" + cstr(sd.point(2).body.id) + "]" + spaces,11)
  680.     l = l + left("point[" + cstr(sd.point(2).id) + "]" + spaces,9)
  681.     l = l + strcell(sd.point(2).px,numdec)
  682.     l = l + strcell(sd.point(2).py,numdec)
  683.     l = l + strcell(sd.damperk,numdec)
  684.     l = l + strnum(sd.currentlength,numdec)
  685.     if sd.alwaysactive then
  686.         l = l + "      Always"
  687.     else
  688.         l = l + "      " + sd.activewhen.formula
  689.     end if
  690.  
  691.     p l
  692.     
  693. end sub
  694.  
  695. sub formatrspring(rs as wmconstraint)
  696. '-------------------------------------------------------------------
  697. '    Formats and prints detail information on the rotaional spring
  698. '     passed to it.
  699. '-------------------------------------------------------------------
  700.     
  701.     dim l as string
  702.     
  703.     p blankline
  704.      l = left("Constraint[" + cstr(rs.id) + "]" + spaces,16)
  705.      l = l + left(rs.name + spaces,11) + "  "
  706.     l = l + left("body[" + cstr(rs.point(1).body.id) + "]" + spaces,11)
  707.     l = l + left("point[" + cstr(rs.point(1).id) + "]" + spaces,9)
  708.     l = l + strcell(rs.point(1).px,numdec)
  709.     l = l + strcell(rs.point(1).py,numdec)
  710.     l = l + strcell(rs.k,numdec)
  711.     if rs.kind = "rotationalspring" then
  712.         l = l + strcell(rs.rotation,numdec)
  713.     end if
  714.     p l
  715.  
  716.     l = string(29, " ") + left("body[" + cstr(rs.point(2).body.id) + "]" + spaces,11)
  717.     l = l + left("point[" + cstr(rs.point(2).id) + "]" + spaces,9)
  718.     l = l + strcell(rs.point(2).px,numdec)
  719.     l = l + strcell(rs.point(2).py,numdec)
  720.     l = l + right("        " + cstr(rs.exponent) + "    ", 12)
  721.     if rs.kind = "rotationalspring" then
  722.         l = l + strnum(rs.currentrotation,numdec)
  723.     end if
  724.     if rs.alwaysactive then
  725.         l = l + "      Always"
  726.     else
  727.         l = l + "      " + rs.activewhen.formula
  728.     end if
  729.  
  730.     p l
  731.     
  732. end sub
  733.  
  734. sub formatrodropesep(rrs as wmconstraint)
  735. '-------------------------------------------------------------------
  736. '    Formats and prints detail information on the rods, ropes, and
  737. '    separators passed to it.
  738. '-------------------------------------------------------------------
  739.     
  740.     dim l as string
  741.     
  742.     p blankline
  743.      l = left("Constraint[" + cstr(rrs.id) + "]" + spaces,16)
  744.      l = l + left(rrs.name + spaces,11) + "  "
  745.     l = l + left(left(rrs.kind,8) + spaces,9)
  746.     l = l + left("body[" + cstr(rrs.point(1).body.id) + "]" + spaces,11)
  747.     l = l + left("point[" + cstr(rrs.point(1).id) + "]" + spaces,9)
  748.     l = l + strcell(rrs.point(1).px,numdec)
  749.     l = l + strcell(rrs.point(1).py,numdec)
  750.     l = l + strcell(rrs.length,numdec)
  751.     if rrs.kind = "rope" or rrs.kind = "separator" then
  752.         l = l + strcell(rrs.elasticity,numdec)
  753.     end if
  754.  
  755.     p l
  756.  
  757.     l = string(38, " ") + left("body[" + cstr(rrs.point(2).body.id) + "]" + spaces,11)
  758.     l = l + left("point[" + cstr(rrs.point(2).id) + "]" + spaces,9)
  759.     l = l + strcell(rrs.point(2).px,numdec)
  760.     l = l + strcell(rrs.point(2).py,numdec)
  761.     if rrs.kind = "rope" or rrs.kind = "separator" then
  762.         l = l + strnum(rrs.currentlength,numdec)
  763.     else
  764.         l = l + "            "
  765.     end if
  766.     if rrs.alwaysactive then
  767.         l = l + "      Always"
  768.     else
  769.         l = l + "      " + rrs.activewhen.formula
  770.     end if
  771.  
  772.     p l
  773.     
  774. end sub
  775.  
  776. sub formatmotact(ma as wmconstraint)
  777. '-------------------------------------------------------------------
  778. '    Formats and prints detail information on the motors and actuators
  779. '     passed to it.
  780. '-------------------------------------------------------------------
  781.     
  782.     dim l as string
  783.     
  784.     p blankline
  785.      l = left("Constraint[" + cstr(ma.id) + "]" + spaces,16)
  786.      l = l + left(ma.name + spaces,11) + "  "
  787.     l = l + left(ma.kind + spaces,9)
  788.     l = l + left("body[" + cstr(ma.point(1).body.id) + "]" + spaces,11)
  789.     l = l + left("point[" + cstr(ma.point(1).id) + "]" + spaces,9)
  790.     l = l + strcell(ma.point(1).px,numdec)
  791.     l = l + strcell(ma.point(1).py,numdec)
  792.     if ma.kind = "motor" then
  793.         l = l + left("    " + ma.motortype + "     ",12)
  794.     else
  795.         l = l + left("    " + ma.actuatortype + "     ",12)
  796.     end if
  797.     if ma.alwaysactive then
  798.         l = l + "      Always"
  799.     else
  800.         l = l + "      " + ma.activewhen.formula
  801.     end if
  802.     p l
  803.  
  804.     l = string(38, " ") + left("body[" + cstr(ma.point(2).body.id) + "]" + spaces,11)
  805.     l = l + left("point[" + cstr(ma.point(2).id) + "]" + spaces,9)
  806.     l = l + strcell(ma.point(2).px,numdec)
  807.     l = l + strcell(ma.point(2).py,numdec)
  808.     l = l + strcell(ma.field,numdec)
  809.     p l
  810.     
  811. end sub
  812.  
  813. sub formatforce(force as wmconstraint)
  814. '-------------------------------------------------------------------
  815. '    Formats and prints detail information on the force passed to it.
  816. '-------------------------------------------------------------------
  817.     
  818.     dim l as string
  819.     
  820.     p blankline
  821.      l = left("Constraint[" + cstr(force.id) + "]" + spaces,16)
  822.      l = l + left(force.name + spaces,11) + "  "
  823.     l = l + left("body[" + cstr(force.point(1).body.id) + "]" + spaces,11)
  824.     l = l + left("point[" + cstr(force.point(1).id) + "]" + spaces,9)
  825.     l = l + strcell(force.point(1).px,numdec)
  826.     l = l + strcell(force.fx,numdec)
  827.     if force.rotatewithbody then
  828.         l = l + "     Yes    "
  829.     else
  830.         l = l + "     No     "
  831.     end if
  832.     if force.alwaysactive then
  833.         l = l + "      Always"
  834.     else
  835.         l = l + "      " + force.activewhen.formula
  836.     end if
  837.     p l
  838.  
  839.     l = string(49," ")
  840.     l = l + strcell(force.point(1).py,numdec)
  841.     l = l + strcell(force.fy,numdec)
  842.     p l
  843.  
  844. end sub
  845.  
  846. sub formattorque(t as wmconstraint)
  847. '-------------------------------------------------------------------
  848. '    Formats and prints detail information on the torque passed to it.
  849. '-------------------------------------------------------------------
  850.     
  851.     dim l as string
  852.     
  853.     p blankline
  854.      l = left("Constraint[" + cstr(t.id) + "]" + spaces,16)
  855.      l = l + left(t.name + spaces,11) + "  "
  856.     l = l + left("body[" + cstr(t.point(1).body.id) + "]" + spaces,11)
  857.     l = l + left("point[" + cstr(t.point(1).id) + "]" + spaces,9)
  858.     l = l + strcell(t.point(1).px,numdec)
  859.     l = l + strcell(t.point(1).py,numdec)
  860.     l = l + strcell(t.torque,numdec)
  861.     if t.alwaysactive then
  862.         l = l + "      Always"
  863.     else
  864.         l = l + "      " + t.activewhen.formula
  865.     end if
  866.     p l
  867.  
  868. end sub
  869.  
  870. sub formatcurvedslot(cs as wmconstraint)
  871. '-------------------------------------------------------------------
  872. '    Formats and prints detail information on the curvedslot passed 
  873. '    to it.
  874. '-------------------------------------------------------------------
  875.     
  876.     dim l as string
  877.     dim i1 as integer
  878.     dim x as double
  879.     dim y as double
  880.     
  881.     p blankline
  882.      l = left("Constraint[" + cstr(cs.id) + "]" + spaces,16)
  883.      l = l + left(cs.name + spaces,11) + "  "
  884.     if not(cs.point(1) is nothing) then
  885.           l = l + left("body[" + cstr(cs.point(1).body.id) + "]" + spaces,11)
  886.           l = l + left("point[" + cstr(cs.point(1).id) + "]" + spaces,9)
  887.           l = l + strcell(cs.point(1).px,numdec)
  888.           l = l + strcell(cs.point(1).py,numdec)
  889.     else
  890.         l = string(75," ")
  891.     end if
  892.     if cs.alwaysactive then
  893.         l = l + "      Always"
  894.     else
  895.         l = l + "      " + cs.activewhen.formula
  896.     end if
  897.     p l
  898.  
  899.     if not(cs.point(2) is nothing) then
  900.         l = string(39, " ") + left("body[" + cstr(cs.point(2).body.id) + "]" + spaces,11)
  901.            l = l + left("point[" + cstr(cs.point(2).id) + "]" + spaces,9)
  902.            l = l + strcell(cs.point(2).px,numdec)
  903.            l = l + strcell(cs.point(2).py,numdec)
  904.     else
  905.         l = string(75," ")
  906.     end if
  907.  
  908.     for i1 = 1 to cs.vertexcount
  909.         cs.getvertex i1,x,y
  910.           l = string(84," ")
  911.         l = l + strnum(x,numdec)
  912.         l = l + strnum(y,numdec)
  913.         p l
  914.     next i1
  915.     
  916. end sub
  917.  
  918. sub formatlinearslot(ls as wmconstraint)
  919. '-------------------------------------------------------------------
  920. '    Formats and prints detail information on the linearslot passed 
  921. '    to it.
  922. '-------------------------------------------------------------------
  923.     
  924.     dim l as string
  925.     dim i1 as integer
  926.     
  927.     p blankline
  928.      l = left("Constraint[" + cstr(ls.id) + "]" + spaces,16)
  929.      l = l + left(ls.name + spaces,11) + "  "
  930.  
  931.     if not(ls.point(1) is nothing) then
  932.           l = l + left("body[" + cstr(ls.point(1).body.id) + "]" + spaces,11)
  933.           l = l + left("point[" + cstr(ls.point(1).id) + "]" + spaces,9)
  934.           l = l + strcell(ls.point(1).px,numdec)
  935.           l = l + strcell(ls.point(1).py,numdec)
  936.         l = l + strcell(ls.point(1).pr,numdec)
  937.     else
  938.         l = string(75," ")
  939.     end if
  940.     if ls.alwaysactive then
  941.         l = l + "    Always"
  942.     else
  943.         l = l + "    " + ls.activewhen.formula
  944.     end if
  945.     p l
  946.  
  947.     if not(ls.point(2) is nothing) then
  948.         l = string(29, " ") + left("body[" + cstr(ls.point(2).body.id) + "]" + spaces,11)
  949.            l = l + left("point[" + cstr(ls.point(2).id) + "]" + spaces,9)
  950.            l = l + strcell(ls.point(2).px,numdec)
  951.            l = l + strcell(ls.point(2).py,numdec)
  952.         l = l + strcell(ls.point(2).pr,numdec)
  953.     else
  954.         l = string(75," ")
  955.     end if
  956.     p l
  957.     
  958. end sub
  959.  
  960. sub formatpulley(pulley as wmconstraint)
  961. '-------------------------------------------------------------------
  962. '    Formats and prints detail information on the pulley passed to it.
  963. '-------------------------------------------------------------------
  964.     
  965.     dim l as string
  966.     dim i1 as integer
  967.     
  968.     p blankline
  969.      l = left("Constraint[" + cstr(pulley.id) + "]" + spaces,16)
  970.      l = l + left(pulley.name + spaces,10) + "   "
  971.       l = l + left("point[" + cstr(pulley.point(1).id) + "]" + spaces,11)
  972.       l = l + left("body[" + cstr(pulley.point(1).body.id) + "]" + spaces,9)
  973.       l = l + strcell(pulley.point(1).px,numdec)
  974.       l = l + strcell(pulley.point(1).py,numdec)
  975.     if pulley.alwaysactive then
  976.         l = l + "    Always"
  977.     else
  978.         l = l + "    " + pulley.activewhen.formula
  979.     end if
  980.     p l
  981.  
  982.     for i1 = 2 to pulley.pointcount
  983.           l = string(29," ")
  984.            l = l + left("point[" + cstr(pulley.point(i1).id) + "]" + spaces,11)
  985.            l = l + left("body[" + cstr(pulley.point(i1).body.id) + "]" + spaces,9)
  986.            l = l + strcell(pulley.point(i1).px,numdec)
  987.            l = l + strcell(pulley.point(i1).py,numdec)
  988.         p l
  989.     next i1
  990.     
  991. end sub
  992.  
  993. sub formatgear(gear as wmconstraint)
  994. '-------------------------------------------------------------------
  995. '    Formats and prints detail information on the gear passed to it.
  996. '-------------------------------------------------------------------
  997.     
  998.     dim l as string
  999.     
  1000.     p blankline
  1001.      l = left("Constraint[" + cstr(gear.id) + "]" + spaces,16)
  1002.      l = l + left(gear.name + spaces,9) + " "
  1003.     l = l + strcell(gear.gearratio,numdec)
  1004.     if gear.rodactive.value = 1 then
  1005.         l = l + "   Active      "
  1006.     else
  1007.         l = l + " Not Active    "
  1008.     end if
  1009.     l = l + left("body[" + cstr(gear.point(1).body.id) + "]" + spaces,11)
  1010.     if gear.internal then
  1011.         if gear.internalbody = gear.point(1).body.id then
  1012.             l = l + " Yes    "
  1013.         else
  1014.                l = l + " No     "
  1015.         end if
  1016.     else
  1017.         l = l + " No     "
  1018.      end if
  1019.     if gear.alwaysactive then
  1020.         l = l + "     Always"
  1021.     else
  1022.         l = l + "     " + gear.activewhen.formula
  1023.     end if
  1024.     p l
  1025.  
  1026.     l = string(53, " ")
  1027.     l = l + left("body[" + cstr(gear.point(2).body.id) + "]" + spaces,11)
  1028.     if gear.internal then
  1029.         if gear.internalbody = gear.point(2).body.id then
  1030.             l = l + " Yes     "
  1031.         else
  1032.                l = l + " No      "
  1033.         end if
  1034.     else
  1035.         l = l + " No      "
  1036.      end if
  1037.  
  1038.     p l
  1039.     
  1040. end sub
  1041.  
  1042. sub PrintPoints
  1043. '-------------------------------------------------------------------
  1044. '    Formats and prints detail information on the point passed to it.
  1045. '-------------------------------------------------------------------
  1046.  
  1047.     dim l as string
  1048.  
  1049.     p blankline
  1050.     p blankline
  1051.     p "Section:  Round and Square Points"
  1052.     p blankline
  1053.     p "Point      Name        Body        Px          Py          Constraint"
  1054.     p string(118,uchar)                                         
  1055.  
  1056.     for i = 1 to mydoc.points.count
  1057.            p blankline
  1058.          l = left("Point[" + cstr(mydoc.points.item(i).id) + "]" + spaces,11)
  1059.          l = l + left(mydoc.points.item(i).name + spaces,11) + " "
  1060.           l = l + left("body[" + cstr(mydoc.points.item(i).body.id) + "]" + spaces,9)
  1061.           l = l + strcell(mydoc.points.item(i).px,numdec)
  1062.           l = l + strcell(mydoc.points.item(i).py,numdec)
  1063.          if not(mydoc.points.item(i).Constraint is nothing) then
  1064.              l = l + right(spaces + "constraint[" + cstr(mydoc.points.item(i).constraint.id) + "]",16)
  1065.           end if
  1066.         p l
  1067.     next i
  1068.  
  1069. end sub
  1070.  
  1071. sub displayhelp
  1072. '-------------------------------------------------------------------
  1073. '    Displays the help dialog box.
  1074. '-------------------------------------------------------------------
  1075.  
  1076.     msgbox "This Working Model Tool writes a file of simulation data" + crlf + _
  1077.            "for the active Working Model document.  Users can select" + crlf + _
  1078.            "what simulation entities to print, and specify the file"  + crlf + _
  1079.            "where the information will be placed." + crlf + crlf + _
  1080.            "A word processor (or Write, which is shipped with Windows)" + crlf + _
  1081.            "can be used to print the file.  To set up the file for" + crlf + _
  1082.            "printing from within a word processor, follow these steps:" + crlf + crlf + _
  1083.            "     1. Open the file from within your word processor" + crlf + _
  1084.            "     2. Select the entire document" + crlf + _
  1085.            "     3. Change the font to <Courier>" + crlf + _
  1086.            "     4. Change the document margins to 0.5 inches on all sides" + crlf + _
  1087.            "     5. Choose landscape mode in the print setup dialog" + crlf + _
  1088.            "     6. Print the document" + crlf + crlf, , "Document Model Help"
  1089.  
  1090.            
  1091.     helpset = false
  1092. end sub
  1093.  
  1094. Function UserAction(ID$, Action%, SuppVal%)
  1095. '-------------------------------------------------------------------
  1096. '    Fills in the main dialog box.  When this routine is first run, 
  1097. '    all selection boxes are checked.  If the user deselects any
  1098. '    boxes, these are retained during subsequent.
  1099. '-------------------------------------------------------------------
  1100.  
  1101.     dim i as integer
  1102.  
  1103.      Select case Action
  1104.      
  1105.      Case 1                ' Dialog box initializes
  1106.  
  1107.         if firstin = 0 then               ' first time running routine
  1108.             DlgValue "header", 1
  1109.             DlgValue "units", 1
  1110.             DlgValue "engine", 1
  1111.             DlgValue "body", 1
  1112.             DlgValue "pins", 1
  1113.             DlgValue "springs", 1
  1114.             DlgValue "dampers", 1
  1115.             DlgValue "springdampers", 1
  1116.             DlgValue "rotsprings", 1
  1117.             DlgValue "rodsropesep", 1
  1118.             DlgValue "motorsactuators", 1
  1119.             DlgValue "force", 1
  1120.             DlgValue "torques", 1
  1121.             DlgValue "linearslot", 1
  1122.             DlgValue "curvedslot", 1
  1123.             DlgValue "pulleys", 1
  1124.             DlgValue "gears", 1
  1125.             DlgValue "points", 1
  1126.             firstin = 5
  1127.         else
  1128.             DlgValue "header", headerflag
  1129.             DlgValue "units", Unitflag
  1130.             DlgValue "engine", engineflag
  1131.             DlgValue "body", bodyflag
  1132.             DlgValue "pins", pinflag
  1133.             DlgValue "springs", springflag
  1134.             DlgValue "dampers", damperFlag
  1135.             DlgValue "springdampers", SpringDamperFlag
  1136.             DlgValue "rotsprings", RotSpringFlag
  1137.             DlgValue "rodsropesep", RodRopeSepFlag
  1138.             DlgValue "motorsactuators", MotorActuatorFlag
  1139.             DlgValue "force", ForceFlag
  1140.             DlgValue "torques", TorqueFlag
  1141.             DlgValue "linearslot", LinearSlotFlag
  1142.             DlgValue "curvedslot", CurvedSlotFlag
  1143.             DlgValue "pulleys", PulleyFlag
  1144.             DlgValue "gears", GearFlag
  1145.             DlgValue "points", PointFlag
  1146.         end if
  1147.  
  1148.      Case 2                  ' User selects a dialog option
  1149.         
  1150.           headerflag = dlgValue("header")
  1151.           Unitflag = dlgValue("units")
  1152.           Engineflag = dlgValue("engine")
  1153.           Bodyflag = dlgValue("body")
  1154.           pinflag = dlgValue("pins")
  1155.           springflag = dlgValue("springs")
  1156.         damperflag = dlgValue("dampers")
  1157.         SpringDamperFlag = dlgvalue("springdampers")
  1158.         RotSpringFlag = dlgvalue("rotsprings")
  1159.         rodropesepflag = dlgvalue("rodsropesep")
  1160.         MotorActuatorFlag = dlgvalue("motorsactuators")
  1161.         ForceFlag = dlgvalue("force")
  1162.         TorqueFlag = dlgvalue("torques")
  1163.         LinearSlotFlag = dlgvalue("linearslot")
  1164.         CurvedSlotFlag = dlgvalue("curvedslot")
  1165.         PulleyFlag = dlgvalue("pulleys")
  1166.         GearFlag = dlgvalue("gears")
  1167.         pointflag = dlgvalue("points")
  1168.  
  1169.       Case Else
  1170.       End Select
  1171.  
  1172. end function
  1173.  
  1174.  
  1175. sub GetPrintParms
  1176. '-------------------------------------------------------------------
  1177. '    Formats the main dialog box.  Calls useraction whenever the user
  1178. '    types or enters anything into the dialog box.
  1179. '-------------------------------------------------------------------
  1180.  
  1181. Begin Dialog PDTemplate 91,22,205,186,"Write Simulation Information",.useraction
  1182.     OKButton 159,8,40,14
  1183.     CancelButton 159,28,40,14
  1184.     CheckBox 10,16,80,8,"Header",.header
  1185.     CheckBox 10,26,80,8,"Unit System",.Units
  1186.     CheckBox 10,36,80,8,"Engine/Integrator",.engine
  1187.     CheckBox 10,63,110,8,"Rectangles, Circles, Polygons",.body
  1188.     Text 5,4,77,8,"Header Information",.Text1
  1189.     Text 5,51,77,8,"Body Information",.Text2
  1190.     CheckBox 10,89,80,8,"Pin Joints",.pins
  1191.     CheckBox 10,99,80,8,"Springs",.springs
  1192.     Text 5,78,77,8,"Constraint Information",.Text3
  1193.     CheckBox 10,109,80,8,"Dampers",.dampers
  1194.     CheckBox 10,119,80,8,"Springs/Dampers",.springdampers
  1195.     CheckBox 10,129,80,8,"Rotational Springs",.rotsprings
  1196.     CheckBox 10,139,94,8,"Rods, Ropes, Separators",.rodsropesep
  1197.     CheckBox 10,149,94,8,"Motors, Actuators",.motorsactuators
  1198.     CheckBox 114,89,82,8,"Forces",.force
  1199.     CheckBox 114,99,82,8,"Torques",.torques
  1200.     CheckBox 114,109,82,8,"Linear Slots",.linearslot
  1201.     CheckBox 114,129,82,8,"Pulleys",.pulleys
  1202.     CheckBox 114,139,82,8,"Gears",.gears
  1203.     PushButton 159,48,40,14,"Help",.help
  1204.     CheckBox 114,119,82,8,"Curved Slots",.curvedslot
  1205.     Text 5,163,77,8,"Pin Information",.Text4
  1206.     CheckBox 10,173,110,8,"Round and Square Points",.points
  1207. End Dialog
  1208.  
  1209.     Dim PD as PDTemplate
  1210.  
  1211.     r% = Dialog(PD,1,0)
  1212.  
  1213.     If r% = 1 then
  1214.         helpset = true
  1215.     else
  1216.         If r% = -1 then
  1217.               helpset = false
  1218.         else
  1219.             helpset = false
  1220.             cancelflag = true
  1221.         end if
  1222.     end if
  1223.  
  1224. end sub
  1225.  
  1226. sub main
  1227. '-------------------------------------------------------------------
  1228. '    Routine that controls program flow.  First asks user for a file
  1229. '    where data can be placed.  On Mac, this must be a filename.  On
  1230. '    Windows, this can be either a file or the ViewPort.
  1231. '    
  1232. '    This routine then displays the main dialog box, displaying the 
  1233. '    help dialog box if the user asks for it.
  1234. '
  1235. '    When the user selects OK, this routine then calls the subroutines
  1236. '    that do printing for each type of Working Model entity the user
  1237. '    requested printing for.      
  1238. '-------------------------------------------------------------------
  1239.  
  1240.  
  1241.     set mydoc = wm.activedocument
  1242.  
  1243.     if (mydoc is Nothing) then
  1244.         MsgBox "No active document exists.", ebExclamation, "Document Model"
  1245.         Exit Sub
  1246.     end if
  1247.  
  1248.     numdec = mydoc.decimaldigits
  1249.     helpset = false
  1250.     cancelflag = false
  1251.  
  1252.     If Basic.OS = ebwin16 or Basic.OS = ebwin32 then    ' Running windows
  1253.         crlf = chr$(13) + chr$(10)
  1254.     else
  1255.         If Basic.OS = ebmacintosh then            ' Running Macintosh
  1256.                crlf = chr$(13)
  1257.            else                            ' Unknown OS
  1258.                MsgBox "Running Unknown Operating System "+Basic.OS
  1259.             exit sub
  1260.            end If
  1261.     end if
  1262.  
  1263.     GetPrintParms
  1264.  
  1265.     If cancelflag then
  1266.         exit sub
  1267.     end if    
  1268.  
  1269.     while helpset
  1270.         displayhelp
  1271.         GetPrintParms
  1272.     wend
  1273.  
  1274.     If cancelflag then
  1275.         exit sub
  1276.     end if    
  1277.  
  1278.     if not openprintfile then
  1279.         exit sub
  1280.     end if
  1281.  
  1282.     If HeaderFlag then
  1283.         PrintHeader
  1284.     End if
  1285.  
  1286.     If UnitFlag then
  1287.         PrintUnits
  1288.     End if
  1289.  
  1290.     if EngineFlag then
  1291.         PrintEngine
  1292.     End if
  1293.  
  1294.     If BodyFlag and (Mydoc.Bodies.count > 0) then
  1295.         PrintBodies
  1296.     End if
  1297.  
  1298.     If Mydoc.constraints.count > 0 then
  1299.         Printconstraints
  1300.     End if
  1301.  
  1302.     if PointFlag and (Mydoc.points.count > 0) then
  1303.         PrintPoints
  1304.     End if
  1305.  
  1306. End Sub
  1307.